<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
   <title>indexpage</title>
</head>
<body>
<a href="./addMessage.html">add new message</a>|<a href="./login.html">login</a>
<hr>
<?php
    $m=new Message(Config::pagesize,$_GET['p']*Config::pagesize);
    $c=count($m);
    $p=(int)$_GET['p'];
    $totalpagecount=(int)($c/Config::pagesize);
    $lastpage=$totalpagecount-1;
    $url= $_SERVER['PHP_SELF'];
    foreach($m as $k=>$v)
    {
        new MessageBox($v);
    }
?>
<hr>
<div align="center">
<?php
    echo "<a href=\"{$url}?p=0\">frist page</a>|";
    for($i=-5;$i<0;$i++)
    {
        $cp=$i+$p;
        if($cp>0)
        {
            echo "<a href=\"{$url}?p={$cp}\">{$cp}</a>|";
        }
    }
    if($p>0&&$p<$lastpage) echo "<a href=\"{$url}?p={$p}\">corrent page</a>|";
    for($i=1;$i<=5;$i++)
    {
        $cp=$i+$p;
        if($cp<$lastpage)
        {
            echo "<a href=\"{$url}?p={$cp}\">{$cp}</a>|";
        }
    }
    echo "<a href=\"{$url}?p={$lastpage}\">last page</a><br/>total {$c} message/total {$totalpagecount} pages";
?>
</div>
</body>
